package net.xdclass.demo.service;

import com.obs.services.ObsClient;
import com.obs.services.model.ObjectListing;
import com.obs.services.model.ObsObject;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

@Service
public class HuaweiObsServiceImpl implements HuaweiObsService {

    @Value("${huawei.obs.endPoint}")
    private String endPoint;
    @Value("${huawei.obs.ak}")
    private String ak;
    @Value("${huawei.obs.sk}")
    private String sk;


    @Override
    public String test() {
        System.out.println(endPoint);
        ObsClient obsClient = new ObsClient(ak, sk, endPoint);
        ObjectListing objectListing = obsClient.listObjects("cps-dev");
        for(ObsObject obsObject : objectListing.getObjects()){
            System.out.println(" - " + obsObject.getObjectKey() + " " + "(size = " +
                    obsObject.getMetadata().getContentLength() + ")");
        }
        return null;
    }

    @Override
    public String uploadFile() {
        return null;
    }
}
